var xmlHttp;

function showHint(str){
	if(str.length==0){
		document.getElementById("txtHint").innerHTML="";
		return;
	}
	//获取XMLHttpObject对象，如果为空，提示浏览器不支持ajax
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}
	//获取url
	var url ="gethint.php";
	url=url+"?q="+str;
	url=url+"&id="+Math.random();
	
	xmlHttp.onreadystatechange=stateChanged;
	//open
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged(){
	if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){
		document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	}
}//注意innerHTML的大小写书写

//获取xml对象
function GetXmlHttpObject(){
	var xmlHttp = null;
	try{
		xmlHttp = new XMLHttpRequest();
	}catch(e){
		try{
			xmlHttp=new ActiveXObject("Msxml2/XMLHTTP");
		}catch(e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}